<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../common/meta.jsp"%>


		<style type="text/css">
* {
	margin: 0;
	padding: 0;
}

.tc_box {
	width: 400px;
	height: 200px;
	border: 2px solid red;
	position: absolute;
	z-index: 2000;
	background: #FFC;
	display: none;
}

.sp_box {
	width: 100%;
	position: absolute;
	z-index: 1000;
	background: #000;
	top: 0;
	left: 0;
	display: none;
}
</style>

		<style>
.main .formdiv {
	width: 400px;
}
</style>
		<script type="text/javascript">
		
		function pwdStreng(password){
						 var flag = false;
						  
						  /** 必须包含数字 */
						  var digit = /\S*[0-9]+\S*/;
						  /** 必须包含英文字符 */
						  var letter = /\S*[a-zA-Z]+\S*/;
						  /** 必须包含特殊字符 */
						  var especialChar = /\S*\W+\S*|\S*[_]+\S*/;
						  if ( digit.test(password)
						    &&  letter.test(password)
						    &&  especialChar.test(password)){
						   flag = true;
						  }
						 
						 return flag;
						}
						
						//alert(pwdStreng("@dddd dd"));
		
		jQuery.validator.addMethod("loginname", function(value, element) {   
    var tel = /^[a-zA-Z][a-zA-Z0-9_]{4,16}$/;
    return this.optional(element) || (tel.test(value));
}, "");

jQuery.validator.addMethod("checkPassword", function(value, element) {   
    var tel =/^(?!(?:[^a-zA-Z]|\D|[a-zA-Z0-9])$).$/;
    return this.optional(element) || (pwdStreng(value));
}, "");

jQuery.validator.addMethod("phonenumber", function(value, element) {   
    var tel = /^(13[0-9]|15[0|3|6|7|8|9]|18[3|6|7|8|9])\d{8}$/;
    return this.optional(element) || (tel.test(value));
}, "");

$(function() {
	
	$("#clear").click(function(){
		$(".inputbox").val("");
	});
	var addForm = $("#addUserForm").validate( {  
		rules : {
			loginName : {
				required : true,
				rangelength:[5,16],
				loginname:true
			},
			userPassword : {
				required : true,
				rangelength:[7,14],
			},
			userPassword2 : {
				required : true,
				equalTo:"#userPassword"
			},
			userName : {
				required : true
			},
			email : {
				required : true,
				email:true
			},
			contactMobile : {
				phonenumber:true
			}
			
		},
		 messages:{
                loginName:{required:"必填",rangelength:"登录名长度5到16位",loginname:"登录名以字母开头，由字母，数字，下划线组成"},
                userPassword:{required:"必填",rangelength:"长度为7到14位"},
                userPassword2:{required:"必填",rangelength:"长度为7到14位",equalTo:"与密码的输入不一致"},
                userName:{required:"必填"},
                email:{required:"必填",email:"非法的邮件地址格式"},
                contactMobile:{required:"必填",phonenumber:"手机号码格式不正确"},
                focusInvalid: false,   
 				onkeyup: false //获得焦点时不验证
 				}
	});



	$("#submit").click(function(){
			if(addForm.form())
			{
			 $("#addUserForm").ajaxSubmit(function(result) {
			 var json =  eval(result);
					var msg=json.msg;
					 
					if (json.result==true) {
						if(json.flag==true)
						{
					 	art.dialog( {
					icon : 'success',
					lock : true,
					resize : false,
					title : "添加成功",
					content : msg,
					ok :function(){
						location.href='${path}/manage/role/index/getAllUsers';
					}
						});
						
						}else
						{
							art.dialog( {
					icon : 'error',
					lock : true,
					resize : false,
					title : "添加失败",
					content : msg
					});
						}
						 
					} else {
					
					alert(msg);
					}
			 
				});
				 
				}
				});
});
</script>
	</head>



	<body id="master">

		<sfa:mainHeader></sfa:mainHeader>
		
		 <!--右边-->
            <div class="webpart3 contentarea">
                <div class="webpart-head">
                    <div class="webpart-head-item">
                        新建用户<font color="red"><c:out value="${add}"></c:out> </font>
                        <div class="tools-btn">
                             
                            &nbsp;&nbsp;<a href="javascript:" onclick="javascript: history.back();"><span>
                                <img src="${path}/statics/images/Redo.gif" style="margin-right: 4px; margin-bottom: -3px;" />返回</span></a></div>
                    </div>
                </div>
                <div class="webpart-main">
                    <div class="webpart-main-item" style="padding: 30px;">
                        <div class="d_formitem">
                        <form id="addUserForm"
					action="${pageContext.request.contextPath }/manage/user/index/add"
					method="post">
                            <table cellspacing="0" cellpadding="0" class="formitem">
                                
                                <tr align="left" >
                                    <th style="width: 60px;">
                                        用户名:
                                    </th>
                                    <td align="left">
                                        
                                        <input type="text" class="input-txt" id="loginName"
										name="loginName" value="${adduser.loginName}" style="width: 40%"/>
										<font color="red">*</font> 
                                    </td>
                                </tr>
                                <tr align="left">
                                    <th>
                                        密&nbsp;&nbsp;码:
                                    </th>
                                    <td>
                                        <input type="password" class="input-txt" id="userPassword" style="width: 40%" 
										name="userPassword" value="${adduser.userPassword}"/>
										<font color="red">*</font> 
                                    </td>
                                </tr>
                                <tr align="left">
                                    <th>
                                        确认密码：
                                    </th>
                                    <td>
                                        <input type="password" class="input-txt" id="userPassword2" style="width: 40%"
										name="userPassword2" value="${userPassword2Form}"/>
										<font color="red">*</font> 
                                    </td>
                                </tr>
                                <tr align="left">
                                    <th>
                                        用户姓名：
                                    </th>
                                    <td>
                                        <input type="text" class="input-txt" id="userName" style="width: 40%"
										name="userName" value="${adduser.userName}"/>
										<font color="red">*</font> 
                                    </td>
                                </tr>
                                <tr align="left">
                                    <th>
                                        电子邮件:
                                    </th>
                                    <td>
                                        
                                        <input type="text" class="input-txt" id="email" name="email" value="${adduser.email}" style="width: 40%"/>
									 
                                    </td>
                                </tr>
                                 <tr align="left">
                                    <th>
                                        手机号码:
                                    </th>
                                    <td>
                                        
                                        <input type="text" class="input-txt" id="contactMobile" style="width: 40%"
										name="contactMobile" value="${adduser.contactMobile}"/>
                                    </td>
                                </tr>
                                
                            </table>
                           
                            <div style="margin: 15px;">
                            <input name="submit" type="button" id="submit" tabindex="5"
										class="linkbtn2" value="提交">
										<input name="clear" type="reset" id="clear" tabindex="5"
										class="linkbtn2" value="重置">
                                 
                            </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="webpart-foot">
                    <div class="webpart-foot-item">
                    </div>
                </div>
            </div>
        
		 
		<sfa:mainFooter></sfa:mainFooter>
	</body>
</html>


